import subprocess
import sys
import os

def build_exe():
    """使用PyInstaller构建exe文件"""
    print("开始构建exe文件...")
    
    # PyInstaller命令
    cmd = [
        "pyinstaller",
        "--onefile",  # 打包成单个exe文件
        "--windowed",  # 不显示控制台窗口
        "--name=DeleteRawFiles",  # 指定exe文件名
        "delete_raw_files.py"
    ]
    
    try:
        # 执行PyInstaller命令
        result = subprocess.run(cmd, capture_output=True, text=True, check=True)
        print("构建成功！")
        print("exe文件位置: dist/DeleteRawFiles.exe")
        return True
    except subprocess.CalledProcessError as e:
        print(f"构建失败: {e}")
        print(f"错误输出: {e.stderr}")
        return False
    except FileNotFoundError:
        print("错误: 未找到PyInstaller。请先安装: pip install pyinstaller")
        return False

if __name__ == "__main__":
    build_exe() 